<!DOCTYPE html><html lang="zh-Hans"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><meta name="description" content="MAC之http命令行工具curl"><meta name="keywords" content="shell"><meta name="author" content="kyren"><meta name="copyright" content="kyren"><title>MAC之http命令行工具curl | Kyren's Blog</title><link rel="shortcut icon" href="/melody-favicon.ico"><link rel="stylesheet" href="/css/index.css?version=1.9.0"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css?version=1.9.0"><meta name="format-detection" content="telephone=no"><meta http-equiv="x-dns-prefetch-control" content="on"><link rel="dns-prefetch" href="https://cdn.jsdelivr.net"><link rel="dns-prefetch" href="https://hm.baidu.com"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?cf87fcdbd9ab7cf93d894f7c219ae78f";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();</script><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><script src="https://v1.hitokoto.cn/?encode=js&amp;charset=utf-8&amp;select=.footer_custom_text" defer></script><script>var GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容:${query}"}},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  hexoVersion: '6.2.0'
} </script><meta name="generator" content="Hexo 6.2.0"></head><body><i class="fa fa-arrow-right" id="toggle-sidebar" aria-hidden="true"></i><div id="sidebar" data-display="true"><div class="toggle-sidebar-info text-center"><span data-toggle="切换文章详情">切换站点概览</span><hr></div><div class="sidebar-toc"><div class="sidebar-toc__title">目录</div><div class="sidebar-toc__progress"><span class="progress-notice">你已经读了</span><span class="progress-num">0</span><span class="progress-percentage">%</span><div class="sidebar-toc__progress-bar"></div></div><div class="sidebar-toc__content"><ol class="toc"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%B8%80%E3%80%81Get%E8%AF%B7%E6%B1%82"><span class="toc-number">1.</span> <span class="toc-text">一、Get请求</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%BA%8C%E3%80%81post%E8%AF%B7%E6%B1%82"><span class="toc-number">2.</span> <span class="toc-text">二、post请求</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#HTTP-GUI-%E5%B7%A5%E5%85%B7"><span class="toc-number"></span> <span class="toc-text">HTTP GUI 工具</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#httpPie"><span class="toc-number"></span> <span class="toc-text">httpPie</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#httpie%E5%AE%89%E8%A3%85"><span class="toc-number">1.</span> <span class="toc-text">httpie安装</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#httpPie%E4%BD%BF%E7%94%A8"><span class="toc-number">2.</span> <span class="toc-text">httpPie使用</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#cookie%E6%93%8D%E4%BD%9C"><span class="toc-number">3.</span> <span class="toc-text">cookie操作</span></a></li></ol></div></div><div class="author-info hide"><div class="author-info__avatar text-center"><img src="https://avatars.githubusercontent.com/u/5827823?v=4"></div><div class="author-info__name text-center">kyren</div><div class="author-info__description text-center">huluo的技术博客</div><div class="follow-button"><a target="_blank" rel="noopener" href="https://github.com/huluo666">Follow Me</a></div><hr><div class="author-info-articles"><a class="author-info-articles__archives article-meta" href="/archives"><span class="pull-left">文章</span><span class="pull-right">239</span></a><a class="author-info-articles__tags article-meta" href="/tags"><span class="pull-left">标签</span><span class="pull-right">41</span></a><a class="author-info-articles__categories article-meta" href="/categories"><span class="pull-left">分类</span><span class="pull-right">29</span></a></div><hr><div class="author-info-links"><div class="author-info-links__title text-center">Links</div><a class="author-info-links__name text-center" target="_blank" rel="noopener" href="http://192.168.2.212:9090/">Jira</a><a class="author-info-links__name text-center" target="_blank" rel="noopener" href="http://192.168.2.212:8090/">Confluence</a><a class="author-info-links__name text-center" target="_blank" rel="noopener" href="http://bloc.leniugame.com/">Leniu</a></div></div></div><div id="content-outer"><div class="no-bg" id="top-container"><div id="page-header"><span class="pull-left"> <a id="site-name" href="/">Kyren's Blog</a></span><i class="fa fa-bars toggle-menu pull-right" aria-hidden="true"></i><span class="pull-right menus">   <a class="site-page" href="/">主页</a><a class="site-page" href="/essay">随笔</a><a class="site-page" href="/archives">归档</a><a class="site-page" href="/tags">标签</a><a class="site-page" href="/categories">分类</a><a class="site-page" href="/about">关于</a></span><span class="pull-right"><a class="site-page social-icon search"><i class="fa fa-search"></i><span> 搜索</span></a></span></div><div id="post-info"><div id="post-title">MAC之http命令行工具curl</div><div id="post-meta"><time class="post-meta__date"><i class="fa fa-calendar" aria-hidden="true"></i> 2017-06-06</time><span class="post-meta__separator">|</span><i class="fa fa-inbox post-meta__icon" aria-hidden="true"></i><a class="post-meta__categories" href="/categories/shell/">shell</a></div></div></div><div class="layout" id="content-inner"><article id="post"><div class="article-container" id="post-content"><p>MAC之http命令行工具curl</p>
<blockquote>
<p>curl是一个向服务器传输数据的工具，支持http、ftp、ftps、scp、sftp、tftp、telnet协议，它可以作为调试接口的利器</p>
</blockquote>
<p>curl默认是GET方法，使用-X参数可以支持其他动词</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">curl -X POST www.baidu.com</span><br><span class="line">curl -X DELETE www.baidu.com</span><br></pre></td></tr></table></figure>

<p><strong>一、基本语法</strong></p>
<blockquote>
<p>-X&#x2F;–request [GET|POST|PUT|DELETE|…] 用于指定请求方式<br>-H&#x2F;–header             设置请求头(header)信息<br>-i&#x2F;–include            请求接口后，输出响应的header信息<br>-d&#x2F;–data               设置请求中的参数<br>-v&#x2F;–verbose            输出更加详细的响应信息</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">curl -X GET &quot;http://www.rest.com/api/users&quot;</span><br><span class="line">curl -X POST &quot;http://www.rest.com/api/users&quot;</span><br><span class="line">curl -X PUT &quot;http://www.rest.com/api/users&quot;</span><br><span class="line">curl -X DELETE &quot;http://www.rest.com/api/users&quot;</span><br></pre></td></tr></table></figure>

<h5 id="一、Get请求"><a href="#一、Get请求" class="headerlink" title="一、Get请求"></a>一、Get请求</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">curl &quot;http://www.baidu.com&quot; 	#如果这里的URL指向的是一个文件或者一幅图都可以直接下载到本地</span><br><span class="line">curl -i &quot;http://www.baidu.com&quot;  #显示全部信息</span><br><span class="line">curl -I &quot;http://www.baidu.com&quot;  #只显示头部信息 HTTP response头信息</span><br><span class="line">curl -v &quot;http://www.baidu.com&quot;  #显示get请求全过程解析</span><br><span class="line">curl http://www.baidu.com/	    #打开网页</span><br><span class="line">curl -o ./baidu.html http://www.baidu.com	#保存网页</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">curl -H &quot;Content-Type:application/json&quot; http://www.baidu.com #添加头</span><br><span class="line">curl --user-agent &quot;[User Agent]&quot; [URL] 					     #添加user agent</span><br></pre></td></tr></table></figure>

<p>post数据或get数据（get就是-X GET)</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">curl -i -H &quot;Accept: application/json&quot; -X POST -d &quot;firstName=james&quot; http://192.168.0.165/persons/person</span><br></pre></td></tr></table></figure>

<h5 id="二、post请求"><a href="#二、post请求" class="headerlink" title="二、post请求"></a>二、post请求</h5><p>直接使用<code>curl</code>只是普通的<code>GET</code>请求</p>
<p>有两种方式进行<code>Post</code>请求：<br>一、使用<code>-d</code>参数，并在后边附上要<code>POST</code>的数据</p>
<p><strong>-d</strong> 参数指定表单以POST的形式执行。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">curl -d &quot;param1=value1&amp;param2=value2&quot; &quot;http://www.baidu.com&quot;</span><br></pre></td></tr></table></figure>

<p>二、直接使用<code>-X</code>参数指明使用请求方法</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">curl -X POST www.example.com</span><br></pre></td></tr></table></figure>

<p>如果接口要求必须使用<code>Content-Type:application/json</code>。可以通过<code>-H</code>参数设置请求头：</p>
<p><code>curl -H &quot;Content-Type:application/json&quot; -d &#39;&#123;&quot;name&quot;: &quot;wcp&quot;&#125;&#39; -i www.example.com/users</code></p>
<p>在http header加入的訊息</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">curl -v -i -H &quot;Content-Type: application/json&quot; http://www.example.com/users</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">huluo:~ luo.h$ curl -h</span><br><span class="line">Usage: curl [options...] &lt;url&gt;</span><br><span class="line">Options: (H) means HTTP/HTTPS only, (F) means FTP only</span><br><span class="line">     --anyauth       Pick &quot;any&quot; authentication method (H)</span><br><span class="line"> -a, --append        Append to target file when uploading (F/SFTP)</span><br><span class="line">     --basic         Use HTTP Basic Authentication (H)</span><br><span class="line"> ...</span><br><span class="line"> -q                  Disable .curlrc (must be first parameter)</span><br></pre></td></tr></table></figure>

<h3 id="HTTP-GUI-工具"><a href="#HTTP-GUI-工具" class="headerlink" title="HTTP GUI 工具"></a>HTTP GUI 工具</h3><p><a target="_blank" rel="noopener" href="http://luckymarmot.com/paw">Paw2</a><br><a target="_blank" rel="noopener" href="http://ditchnet.org/httpclient/">HTTP Client</a><br><a target="_blank" rel="noopener" href="http://ditchnet.org/httpclient/">Cocoa Rest Client</a><br><a target="_blank" rel="noopener" href="https://github.com/jakubroztocil/httpie">https://github.com/jakubroztocil/httpie</a><br><a target="_blank" rel="noopener" href="https://github.com/mmattozzi/cocoa-rest-client">https://github.com/mmattozzi/cocoa-rest-client</a><br><a target="_blank" rel="noopener" href="https://github.com/ACENative/ACEView">https://github.com/ACENative/ACEView</a><br><a target="_blank" rel="noopener" href="https://curl.haxx.se/docs/manpage.html#-d">https://curl.haxx.se/docs/manpage.html#-d</a></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">curl --data  &#x27;username=kele8&amp;password=123456test&#x27; &#x27;https://v46.pcauto.com.cn/passport3/rest/login_new.jsp&#x27;</span><br><span class="line">curl -X POST -d &quot;username=kele8&quot; -d &quot;password=123456test&quot; https://v46.pcauto.com.cn/passport3/rest/login_new.jsp</span><br><span class="line"></span><br><span class="line">//保存cookie</span><br><span class="line">curl -D sugarcookies -X POST -d &quot;username=kele8&quot; -d &quot;password=123456test&quot; https://v46.pcauto.com.cn/passport3/rest/login_new.jsp</span><br></pre></td></tr></table></figure>


<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">使用`&amp;`串接多個参数</span></span><br><span class="line">curl -X POST -d &quot;username=kele8&amp;password=123456test&quot; yourURl</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">也可使用多个`-d`，效果同上</span></span><br><span class="line">curl -X POST -d &quot;username=kele8&quot; -d &quot;password=123456test&quot;</span><br><span class="line">curl -X POST -d &quot;param1=a 0space&quot;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">&quot;a space&quot;</span> url encode后空白字元会编码成<span class="string">&#x27;%20&#x27;</span>为<span class="string">&quot;a%20space&quot;</span>，编码后的参数可以直接使用</span></span><br><span class="line">curl -X POST -d &quot;param1=a%20space&quot;</span><br><span class="line"></span><br><span class="line">curl -i -X POST -b &quot;common_session_id1=BA9A8CCFE21CDD38D4A79EC8CE10DA45955B13C980CF88CE6293706A3549C7B83EC4C96FE99E0313&quot; -d username=kele8 -d password=123456test -c  ~/cookie.txt  https://v46.pcauto.com.cn/passport3/rest/login_new.jsp</span><br><span class="line"></span><br><span class="line">curl  &quot;common_session_id1=BA9A8CCFE21CDD38D4A79EC8CE10DA45955B13C980CF88CE6293706A3549C7B83EC4C96FE99E0313&quot; -X POST -d &quot;nodeId=13814&amp;topicId=14140213&amp;content=uuu]&quot;</span><br><span class="line"></span><br><span class="line">    curl -X POST -c cookies.txt -u &quot;Uern@me:P@ssw0rd&quot; https://login.three.ie/</span><br><span class="line"></span><br><span class="line">http://v71.pcauto.com.cn/zxapi/1/topic/live/node/update.ajax</span><br></pre></td></tr></table></figure>

<h3 id="httpPie"><a href="#httpPie" class="headerlink" title="httpPie"></a>httpPie</h3><p><code>httpPie</code>相比<code>Curl</code>的好处是：返回值信息有语法高亮、对返回的JSON字符串自动格式化。</p>
<h5 id="httpie安装"><a href="#httpie安装" class="headerlink" title="httpie安装"></a>httpie安装</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">brew install httpie</span></span><br></pre></td></tr></table></figure>

<h5 id="httpPie使用"><a href="#httpPie使用" class="headerlink" title="httpPie使用"></a>httpPie使用</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">http -f POST www.baidu.com name=name  #模拟表单提交</span><br><span class="line">http -v www.baidu.com     #显示详细的请求信息</span><br><span class="line">http -h www.baidu,com     #仅显示Header</span><br><span class="line">http -b www.baidu.com     #仅显示Body</span><br><span class="line">http -d www.baidu.com     #下载文件</span><br><span class="line"></span><br><span class="line">http PUT www.baidu.com name=name password=pwd  #传递json类型参数（字符串）</span><br><span class="line">http PUT www.baidu.com age:=28 				   #非字符串类型使用：=分割</span><br><span class="line">http --form POST www.baidu.com name=&#x27;name&#x27;     #模拟form的POST请求</span><br><span class="line">http -f POST www.baidu.com/files  name=&#x27;name&#x27; file@~/test.txt  #模拟form文件上传</span><br><span class="line">http www.baidu.com User-Agent:Txl/1.0 &#x27;Cookie:a=b;b=c&#x27; Referer:http://www.baidu.com/</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">修改请求头，使用：分割</span></span><br><span class="line"></span><br><span class="line">http -a username:password www.baidu.com   #认证</span><br><span class="line">http --auth--type=digest -a user:pwd www.baidu.com  #认证</span><br><span class="line">http --proxy=http:http://192.168.1.1:8080 www.baidu.com</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">使用HTTP代理</span></span><br></pre></td></tr></table></figure>

<p>了解http原理， <a target="_blank" rel="noopener" href="https://launchschool.com/books/http">Introduction to HTTP</a> 是一个不错的选择，也可以参考它的中文翻译版: <a target="_blank" rel="noopener" href="https://www.kancloud.cn/kancloud/tealeaf-http">HTTP 下午茶</a></p>
<h5 id="cookie操作"><a href="#cookie操作" class="headerlink" title="cookie操作"></a>cookie操作</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">curl -D sugarcookies -X POST -d &quot;username=kele8&quot; -d &quot;password=123456test&quot; https://v46.pcauto.com.cn/passport3/rest/login_new.jsp</span><br><span class="line">curl -D sugarcookies -d &quot;username=kele8&quot; -d &quot;password=123456test&quot; https://v46.pcauto.com.cn/passport3/rest/login_new.jsp</span><br><span class="line">curl -b sugarcookies  https://v80.pcauto.com.cn/xsp/s/club/v4.7/getNewMsgCount.xsp?userId=43970286</span><br><span class="line">curl -b &#x27;/Users/pconline/Documents/sugarcookies&#x27; https://v80.pcauto.com.cn/xsp/s/club/v4.7/getNewMsgCount.xsp?userId=43970286</span><br><span class="line">curl -b sugarcookies https://v80.pcauto.com.cn/xsp/s/club/v4.7/getNewMsgCount.xsp?userId=43970286</span><br><span class="line">curl  -H  &quot;&quot; https://v80.pcauto.com.cn/xsp/s/club/v4.7/getNewMsgCount.xsp?userId=43970286</span><br></pre></td></tr></table></figure>

<p>其它字段释义</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">-v/--verbose 			小写的v参数，用于打印更多信息，包括发送的请求信息，这在调试脚本是特别有用。</span><br><span class="line">-m/--max-time &lt;seconds&gt; 指定处理的最大时长</span><br><span class="line">-H/--header &lt;header&gt; 	指定请求头参数</span><br><span class="line">-s/--slient 			减少输出的信息，比如进度</span><br><span class="line">--connect-timeout &lt;seconds&gt; 指定尝试连接的最大时长</span><br><span class="line">-x/--proxy &lt;proxyhost[:port]&gt; 指定代理服务器地址和端口，端口默认为1080</span><br><span class="line">-T/--upload-file &lt;file&gt; 指定上传文件路径</span><br><span class="line">-o/--output &lt;file&gt; 		指定输出文件名称</span><br><span class="line">-d/--data/--data-ascii &lt;data&gt; 指定POST的内容</span><br><span class="line">--retry &lt;num&gt;			指定重试次数</span><br><span class="line">-e/--referer &lt;URL&gt; 		指定引用地址</span><br><span class="line">-I/--head			    仅返回头部信息，使用HEAD请求</span><br></pre></td></tr></table></figure>



<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">-w  定义curl的输出格式，</span><br><span class="line"><span class="meta prompt_">%</span><span class="language-bash">&#123;http_code&#125;则为获取curl获取URL的http状态码</span></span><br><span class="line">时间指标解释 ：</span><br><span class="line">time_connect    建立到服务器的 TCP 连接所用的时间</span><br><span class="line">time_starttransfer    在发出请求之后，Web 服务器返回数据的第一个字节所用的时间</span><br><span class="line">time_total   完成请求所用的时间</span><br><span class="line">在 发出请求之后，Web 服务器处理请求并开始发回数据所用的时间是</span><br><span class="line">（time_starttransfer）1.044 - （time_connect）0.244 = 0.8 秒</span><br><span class="line">客户机从服务器下载数据所用的时间是</span><br><span class="line">（time_total）2.672 - （time_starttransfer）1.044 = 1.682 秒</span><br><span class="line">其他常用常用http变量</span><br><span class="line">http_code:http返回类似404,200,500等</span><br><span class="line">time_total:总相应时间</span><br><span class="line">time_namelookup:域名解析时间</span><br><span class="line">time_connect:连接到目标地址耗费的时间</span><br><span class="line">time_pretransfer:从执行到开始传输文件的时间间隔</span><br><span class="line">time_starttransfer:从执行到开始传输文件的时间间隔</span><br><span class="line">size_download:下载网页或文件大小</span><br><span class="line">size_upload:上传文件大小</span><br><span class="line">size_header:响应头</span><br><span class="line">size_request:发送请求参数大小</span><br><span class="line">speed_download：传输速度</span><br><span class="line">speed_upload:平均上传速度</span><br><span class="line">content_type:下载文件类型.</span><br></pre></td></tr></table></figure>

<p>更多Http，Curl讲解<br><a target="_blank" rel="noopener" href="http://php.net/manual/zh/function.curl-getinfo.php">http://php.net/manual/zh/function.curl-getinfo.php</a><br><a target="_blank" rel="noopener" href="https://orrsella.com/2014/10/06/http-request-diagnostics-with-curl/">https://orrsella.com/2014/10/06/http-request-diagnostics-with-curl/</a><br><a target="_blank" rel="noopener" href="https://ec.haxx.se/usingcurl-verbose.html">https://ec.haxx.se/usingcurl-verbose.html</a><br><a target="_blank" rel="noopener" href="https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/curl.1.html">https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/curl.1.html</a><br><a target="_blank" rel="noopener" href="http://coderlt.coding.me/2016/03/22/mac-command-curl/">MAC之http命令行工具curl</a><br><a target="_blank" rel="noopener" href="https://tonydeng.github.io/2015/07/10/httpie-howto/">HTTPie:超爽的HTTP命令行客户端</a><br><a target="_blank" rel="noopener" href="http://lingxiankong.github.io/blog/2014/08/19/curl-httpie/">http://lingxiankong.github.io/blog/2014/08/19/curl-httpie/</a><br><a target="_blank" rel="noopener" href="http://www.ruanyifeng.com/blog/2011/09/curl.html">http://www.ruanyifeng.com/blog/2011/09/curl.html</a><br>curl命令用法<br><a target="_blank" rel="noopener" href="http://ju.outofmemory.cn/entry/84875">http://ju.outofmemory.cn/entry/84875</a><br><a target="_blank" rel="noopener" href="http://jockchou.github.io/blog/2016/01/23/curl.html">http://jockchou.github.io/blog/2016/01/23/curl.html</a><br>使用CURL来调试你的应用<br><a target="_blank" rel="noopener" href="http://stormzhang.com/devtools/2014/11/07/use-curl-debug/">http://stormzhang.com/devtools/2014/11/07/use-curl-debug/</a><br><a target="_blank" rel="noopener" href="http://man.linuxde.net/curl">http://man.linuxde.net/curl</a><br><a target="_blank" rel="noopener" href="https://xin053.github.io/2016/08/15/httpie%E4%BA%BA%E6%80%A7%E5%8C%96curl%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8%E8%AF%A6%E8%A7%A3/">httpie人性化curl工具使用详解</a><br>Curl with Cookies and Headers<br><a target="_blank" rel="noopener" href="http://joelpm.com/curl/tools/2010/06/17/curl-with-cookies-and-headers.html">http://joelpm.com/curl/tools/2010/06/17/curl-with-cookies-and-headers.html</a><br>使用curl指令測試REST服務<br><a target="_blank" rel="noopener" href="http://blog.kent-chiu.com/2013/08/14/testing-rest-with-curl-command.html">http://blog.kent-chiu.com/2013/08/14/testing-rest-with-curl-command.html</a><br><a target="_blank" rel="noopener" href="https://github.com/atg/taskit">https://github.com/atg/taskit</a><br><a target="_blank" rel="noopener" href="https://github.com/jakubroztocil/httpie">https://github.com/jakubroztocil/httpie</a></p>
</div></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">kyren</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://huluo666.gitee.io/2017/06/06/MAC之http命令行工具/">http://huluo666.gitee.io/2017/06/06/MAC之http命令行工具/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://huluo666.gitee.io">Kyren's Blog</a>！</span></div></div><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/shell/">shell</a></div><nav id="pagination"><div class="prev-post pull-left"><a href="/2017/08/02/%E4%BD%BF%E7%94%A8%20CSSJSON%20Converts%20CSS%20to%20JSON/"><i class="fa fa-chevron-left">  </i><span>iOS使用js库实现css转换json</span></a></div><div class="next-post pull-right"><a href="/2017/06/05/Xcode8%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91/"><span>Xcode8插件开发</span><i class="fa fa-chevron-right"></i></a></div></nav></div></div><footer><div class="layout" id="footer"><div class="copyright">&copy;2022 By kyren</div><div class="framework-info"><span>驱动 - </span><a target="_blank" rel="noopener" href="http://hexo.io"><span>Hexo</span></a><span class="footer-separator">|</span><span>主题 - </span><a target="_blank" rel="noopener" href="https://github.com/Molunerfinn/hexo-theme-melody"><span>Melody</span></a></div><div class="footer_custom_text">hitokoto</div><div class="busuanzi"><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><span id="busuanzi_container_page_pv"><i class="fa fa-file"></i><span id="busuanzi_value_page_pv"></span><span></span></span></div></div></footer><i class="fa fa-arrow-up" id="go-up" aria-hidden="true"></i><script src="https://cdn.jsdelivr.net/npm/animejs@latest/lib/anime.min.js"></script><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-animate@latest/velocity.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-ui-pack@latest/velocity.ui.min.js"></script><script src="/js/utils.js?version=1.9.0"></script><script src="/js/fancybox.js?version=1.9.0"></script><script src="/js/sidebar.js?version=1.9.0"></script><script src="/js/copy.js?version=1.9.0"></script><script src="/js/fireworks.js?version=1.9.0"></script><script src="/js/transition.js?version=1.9.0"></script><script src="/js/scroll.js?version=1.9.0"></script><script src="/js/head.js?version=1.9.0"></script><script src="/js/search/local-search.js"></script><script>if(/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)) {
  $('#nav').addClass('is-mobile')
  $('footer').addClass('is-mobile')
  $('#top-container').addClass('is-mobile')
}</script><div class="search-dialog" id="local-search"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章"></div></div></div><hr><div id="local-search-results"><div id="local-hits"></div><div id="local-stats"><div class="local-search-stats__hr" id="hr"><span>由</span> <a target="_blank" rel="noopener" href="https://github.com/wzpan/hexo-generator-search" style="color:#49B1F5;">hexo-generator-search</a>
 <span>提供支持</span></div></div></div><span class="search-close-button"><i class="fa fa-times"></i></span></div><div class="search-mask"></div></body></html>